function ZhajinhuaResult() {
    this.uid = 0;
    this.cards = "";
    this.score = 0;
    this.cardType = 0;
    this.blindFlag = 0;
    this.foldFlag = 0;
    this.compareLoseFlag = 0;
    this.compareOpponentUid = 0;
    this.compareFlag = 0;
    this.betChips = 0;
    this.betTimes = 0;
}

ZhajinhuaResult.prototype.toBSON = function() {
    return {
        uid : this.uid,
        cards : this.cards,
        score : this.score,
        cardType : this.cardType,
        blindFlag: this.blindFlag,
        foldFlag : this.foldFlag,
        compareLoseFlag : this.compareLoseFlag,
        compareOpponentUid : this.compareOpponentUid,
        compareFlag: this.compareFlag,
        betChips : this.betChips,
        betTimes : this.betTimes,
    };
};

ZhajinhuaResult.prototype.toJSON = function () {
    return {
        uid : this.uid,
        cards : this.cards,
        score : this.score,
        cardType : this.cardType,
        blindFlag: this.blindFlag,
        foldFlag : this.foldFlag,
        compareLoseFlag : this.compareLoseFlag,
        compareOpponentUid : this.compareOpponentUid,
        compareFlag: this.compareFlag,
        betChips : this.betChips,
        betTimes : this.betTimes,
    };
};

module.exports.create = function(uid, cards, score, cardType, blindFlag, foldFlag, compareLoseFlag,
                                 compareOpponentUid, compareFlag, betChips, betTimes) {
    let zhajinhuaResult = new ZhajinhuaResult();
    zhajinhuaResult.uid = uid;
    zhajinhuaResult.cards = cards;
    zhajinhuaResult.score = score;
    zhajinhuaResult.cardType = cardType;
    zhajinhuaResult.blindFlag = blindFlag;
    zhajinhuaResult.foldFlag = foldFlag;
    zhajinhuaResult.compareLoseFlag = compareLoseFlag;
    zhajinhuaResult.compareOpponentUid = compareOpponentUid;
    zhajinhuaResult.compareFlag = compareFlag;
    zhajinhuaResult.betChips = betChips;
    zhajinhuaResult.betTimes = betTimes;
    return zhajinhuaResult;
};

module.exports.loadFromDocument = function (document) {
    let result = new ZhajinhuaResult();
    result.uid = document["uid"];
    result.cards = document["cards"];
    result.score = document["score"];
    result.cardType = document["cardType"];
    result.blindFlag = document["blindFlag"];
    result.foldFlag = document["foldFlag"];
    result.compareLoseFlag = document["compareLoseFlag"];
    result.compareOpponentUid = document["compareOpponentUid"];
    result.compareFlag = document["compareFlag"];
    result.betChips = document["betChips"];
    result.betTimes = document["betTimes"];
    return result;
};
